package com.mm.domain;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.Set;

/**
 * 自定义安全用户
 */
public class SecurityUser extends User implements UserDetails {
    private String username;    //用户真实帐号
    private String password;    //用户真实密码

    private Set<GrantedAuthority> authorities;  //用户权限
    private boolean accountNonExpired;      //账户是否未过期(true:未过期,false:过期)
    private boolean accountNonLocked;       //账户是否未锁定(true:未锁定,false:锁定)
    private boolean credentialsNonExpired;  //凭证是否未过期(true:未过期,false:过期)
    private boolean enabled;                //是否可用(true:可用,false:不可用)

    public SecurityUser() {
    }

    public SecurityUser(String username,String password,Set<GrantedAuthority> authorities, boolean accountNonExpired, boolean accountNonLocked, boolean credentialsNonExpired, boolean enabled) {
        this.username = username;
        this.password = password;
        this.authorities = authorities;
        this.accountNonExpired = accountNonExpired;
        this.accountNonLocked = accountNonLocked;
        this.credentialsNonExpired = credentialsNonExpired;
        this.enabled = enabled;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public boolean isAccountNonExpired() {
        return accountNonExpired;
    }

    @Override
    public boolean isAccountNonLocked() {
        return accountNonLocked;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return credentialsNonExpired;
    }

    @Override
    public boolean isEnabled() {
        return enabled;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public String getPassword() {
        return password;
    }
}
